<!DOCTYPE html>
<html>

<title>我的收藏</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script>
	$(function() {
		//查询用户信息
		$("#u_inf").hide();
		$("#logout").hide();
		$("#bg").hide();
		$("#nocoll").hide();
		$.get("./fillServlet", {}, function(data) {
			//{uid:1,name:'李四'}
			if (data != null && data.length != 0) {
				$("#reg").hide();
				$("#no_reg").hide();
				$("#u_inf").show();
				$("#logout").show();
				$("#bg").show();
				$("#u_inf").text("欢迎," + data.username);
				var uid = data.uid;
				$.get("./favorDetialServlet",{uid:uid},function(inf){
					var list = '';
					if(inf==null||inf.length==0)
						$("#nocoll").show();
					else 
					for(var i=0;i < inf.length ;i++){
						var div = '<div class="col-sm-6 col-md-4" id="pad">'+
										 '<div class="thumbnail" id="specific">'+
											'<img src="'+inf[i].img1+'">'+
											' <div class="caption">'+
												'<h4>'+inf[i].dname+'</h4>'+
												'<p>'+inf[i].detial+'</p>'+
													'<a href="./detailed.html?foodid='+inf[i].foodid+'" class="btn btn-primary" role="button">查看详情</a>'+ 
													'<a href="javascript:cancel('+inf[i].foodid+');" class="btn btn-danger" role="button" >取消收藏</a> '+
											'</div>'+
										'</div>'+
									'</div>'
						list += div;
					}
					$("#favorite").html(list);
					
					
				});
			} else {
				$("#reg").show();
			}
		});
	});
	
	function cancel(foodid) {
		$.get("./delfavoriteServlet",{foodid:foodid},function(dd){
			window.location.reload();
		});
		
	}
</script>

<style type="text/css">
#first {
	border: gray 2px solid;
	background: url("./img/header_bg.jpg") no-repeat;
	background-size: 100%;
	height: 120px;
	border-radius: 10px;
}

#p1 {
	color: #D3D3D3;
	font-style: oblique;
	font-size: 40px;
	font-family: "华文琥珀";
	margin-top: 28px;
	margin-left: 40px;
	float: left;
}

#p2 {
	color: black;
	font-size: 25px;
	font-family: "仿宋";
	padding-top: 45px;
	margin-left: 480px;
}

#word {
	width: 80px;
	height: 80px;
}

#xx {
	width: 75px;
	height: 105px;
}

.footer {
	text-align: center;
	margin-top: 50px;
	margin-bottom: 20px;
}

h3 {
	text-align: center;
}

#bg{
   background: #F8F8FF;
   border-radius: 10px; 
}

#pad{
   margin: 15px 5px 0 0;
   width: 385px;
}

#pad a{
   margin: 5px 10px 0 0;
}

#pad p{
   color: gray;
}

#pad img {
	height: 218px;
	width: 360px;
}

#specific{
   height: 430px;
}

</style>
</head>
<body>
	<div class="container-fluid">
		<div class="row" id="first"></div>
		<div class="row">
			<nav class="navbar navbar-inverse">
				<div class="container-fluid">
					<!-- Brand and toggle get grouped for better mobile display -->
					<div class="navbar-header">
						<button type="button" class="navbar-toggle collapsed"
							data-toggle="collapse"
							data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
							<span class="sr-only">Toggle navigation</span> <span
								class="icon-bar"></span> <span class="icon-bar"></span> <span
								class="icon-bar"></span>
						</button>
						<a class="navbar-brand" href="./index.html">首页</a>
					</div>

					<!-- Collect the nav links, forms, and other content for toggling -->
					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">
							<li class="active"><a href="#">我的收藏 <span
									class="sr-only">(current)</span></a></li>
						</ul>
						<form class="navbar-form navbar-right" role="search" action="./searchlist.html">
							<div class="form-group">
								<input type="text" class="form-control" placeholder="关键词搜索"  name="keyword">
								<input name="currentpage" value=0 style="display: none;">
							</div>
							<input type="submit" id="sss" value="搜索"  class="btn btn-default ">
						</form>
						<ul class="nav navbar-nav navbar-right">
							<li><a href="./register.html">注册</a></li>
							<li><a id=u_inf></a></li>
							<li id=reg><a href="./Login.jsp">登录</a></li>
							<li id=logout><a
								href="javascript:location.href='userLogoutServlet';">退出登录</a></li>
						</ul>
					</div>
				</div>
			</nav>
		</div>
	</div>

	
		<h3 id="no_reg">
			对不起，您还未登录，请返回<a href="./Login.jsp">登录</a>
		</h3>
	
        <h3 id="nocoll">
			您还没有收藏，去<a href="./first.html">浏览</a>看看吧
		</h3>
	<div class="container" id="bg">
		<div class="row"  id="favorite">

		</div>
	</div>


	<div class="footer">
		<hr>
		Copyright © 2020, <a href="./index.html">&#160&#160嗣食肆&#160</a>&#160All
		Rights Reserved
	</div>
</body>
</html>